Reduce background Git ref and port polling#4187
Conversation
- Poll first ref pages every 20 seconds and refresh menus on open - Avoid duplicate port scans and adapt lsof polling to activity - Document the retained freshness guarantees
…nd-git-ref-port-polling
…nd-git-ref-port-polling
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review Changes polling intervals and adds concurrency serialization across multiple subsystems (VCS refs, port scanning, websocket handling). The behavioral scope affecting system responsiveness and new semaphore-based ordering warrants human review. You can customize Macroscope's approvability policy. Learn more. |
…nd-git-ref-port-polling
- Order subscription replay with concurrent snapshot broadcasts - Cover replay ordering with a focused concurrent regression test - Document the preview notification ordering guarantee
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
- Distinguish upstream behavior origin from branch helper ownership - Describe helper unit coverage without implying component integration
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
- Remove listeners immediately when initial snapshot replay fails - Cover continued broadcasts after a defective replay
Dismissing prior approval to re-evaluate 33063a2
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 33063a2. Configure here.
- Prevent slow scans from overwriting newer snapshots - Cover concurrent scan ordering with a deterministic regression

Summary
Reduce persistent background work from Git ref enumeration and preview port discovery while preserving freshness when users interact with either surface.
What Changed
Why
During extended use, T3 Code's resident memory climbed past 6 GB even while idle, while the renderer sustained roughly 10% CPU and the machine became noticeably warm around the CPU and GPU clusters. That pattern indicated that background work was continuing without user interaction and could compound renderer and resource pressure over long sessions.
Diagnostics identified two repeatable sources of idle churn: every retained Git-ref query, including each loaded pagination page, owned its own five-second
listRefsrevalidation loop, while preview discovery launched a broadlsofscan every three seconds. Preview subscription initialization could also scan twice, and unchanged terminal process registrations caused redundant probes. The new schedules reduce that steady subprocess load while immediate menu refreshes, terminal-process-triggered scans, and adaptive safety-net polling preserve freshness at interaction time.Validation
git diff --checkpassedProof
No standalone proof artifacts were captured; the isolated browser verification is summarized above.
Note
Medium Risk
Touches preview discovery concurrency and VCS ref freshness schedules; incorrect ordering or replay could briefly show stale ports or refs, but changes are well-covered by focused PortScanner and vcs tests.
Overview
Cuts idle background work from Git ref polling and preview port discovery while keeping data fresh when users open branch or comparison menus.
VCS refs (
vcs.ts): First-page revalidation moves from 5s → 20s; paginated cursor pages no longer tick on an interval. Inactive ref atoms expire after 30s (was 5 minutes).BranchToolbarBranchSelectorandDiffPanelsharerefreshVcsRefsOnMenuOpenso local (and remote for Diff) refs refresh only when a menu opens, not on close.Port discovery (
PortScanner.ts,ws.ts): Broadlsofpolling drops from 3s to 10s when listeners are known and 20s when idle. Scans and snapshot publish/replay are serialized (semaphores) so slow scans and concurrent subscribers cannot deliver stale results; failed initial replay unregisters the listener. Terminal PID registration triggers scans only when the process set actually changes. WebSocketsubscribeDiscoveredLocalServersdrops its duplicate initialscan()—subscribers get the latest snapshot viaPortDiscovery.subscribereplay afterretain.Tests and
BRANCH_DETAILS.mddocument the new intervals and concurrency behavior.Reviewed by Cursor Bugbot for commit 1863288. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Reduce background Git ref and port polling intervals
listRefsatom idle TTL drops from 5 minutes to 30 seconds in vcs.tsrefreshVcsRefsOnMenuOpenhelper; background polling no longer handles this on its ownMacroscope summarized 1863288.